<?php

namespace App\Http\Controllers\Common;

use App\Http\Controllers\BaseController;
use App\Models\System\SystemNotifyCenterModel;
use App\Service\Common\InformationService;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;

class InformationController extends BaseController
{
    /**
     * 商家APP消息推送
     * @param Request $request
     * @return JsonResponse
     */
    public function appBasePush(Request $request): JsonResponse
    {
        $title        = $request->post('title', '');
        $notifyType   = $request->post('notifyType', SystemNotifyCenterModel::NOTIFY_TYPE_3);
        $target       = $request->post('target', SystemNotifyCenterModel::NOTIFY_TARGET_1);
        $sms          = $request->post('sms', '');
        $url          = $request->post('url', '');
        $methodType   = $request->post('methodType', SystemNotifyCenterModel::METHOD_TYPE_AUTOMATIC);
        $summary      = $request->post('summary', '');
        $contents     = $request->post('contents', '');
        $isPopup      = $request->post('isPopup', SystemNotifyCenterModel::IS_POPUP_OFF);
        $presenceArea = $request->post('presenceArea', '1');
        $pushInfo     = $request->post('pushInfo', []);
        $shopId       = $request->post("shopId", 0);
        InformationService::appBasePush($title, $notifyType, $target, $sms, $url, $methodType, $summary, $contents,
            $isPopup, $presenceArea, $pushInfo, $shopId);
        return $this->success();
    }
}
